#ifndef _table
#define _table

#include <iostream>
#include <deque>
#include <map>
#include "link.h"

using namespace std;

#if defined(GENERIC)
class Table {
	// Students should write this class

public:
	ostream & Print(ostream &os) const;
};
#endif

/////////////////////////////////////////////////////////////
// 
// Link State
// 
/////////////////////////////////////////////////////////////


#if defined(LINKSTATE)

class Table {
private:
	// dest, the links to the dest
	map<unsigned, deque<Link *> > m_rTable;
	unsigned int m_uintNodeID;

	// Students should write this class
public:
	Table();
	Table(map<unsigned int, deque<Link *> > outerMap, unsigned int uintNodeID);
	~Table();


	void Print(unsigned int uintNodeID);
	ostream & Print(ostream &os);
	unsigned int GetNextHopNode(unsigned int dest);
	double GetNextHopCost(unsigned int dest);
	Link * GetNextHopLink(unsigned int dest);
	void SetNextHopLink(unsigned int dest, Link * nextLink);


	void SetShortestPath(unsigned dest, deque<Link *> path);
	deque<Link *> GetShortestPath(unsigned dest);
	void clear();
};
#endif

/////////////////////////////////////////////////////////////
// 
// Distance Vector
// 
/////////////////////////////////////////////////////////////


#if defined(DISTANCEVECTOR)

//#include "node.h"

class Table
{
private:
	// private member variables
	//vector<vector<double> > m_rTable;
	map<unsigned int, map<unsigned int, double> > m_rTable;
	unsigned int m_uintNodeID;

public:
	Table();
	Table(map<unsigned int, map<unsigned int, double> > outerMap, unsigned int uintNodeID);
	~Table();

	void Print(unsigned int uintNodeID);
	double GetRoutingCost(unsigned int source, unsigned int dest);
	void SetRoutingValue(unsigned int source, unsigned int dest, double cost);
	void SetInnerMapValue(map<unsigned int, map<unsigned int, double> >::iterator outerMapIT, map<unsigned int, double> newMap);
	map<unsigned int, map<unsigned int, double> >::iterator Begin();
	map<unsigned int, map<unsigned int, double> >::iterator End();
	map<unsigned int, map<unsigned int, double> >::iterator Find(unsigned int uintSource);
	map<unsigned int, double> GetRoutingValueVector(unsigned source);
	ostream & Print(ostream &os);
};
#endif // defined(DISTANCEVECTOR)

inline ostream & operator<<(ostream &os, Table &t) {
	return t.Print(os);
}

#endif
